package com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00102;

import com.example.modelviewpresenter.Model.BasterModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00107.BaseDay00107Api;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00107.BaseDay00107Bean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00107.BaseDay00107Okhttp;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 作者:二徒
 * 时间：2021/10/28- 11:17
 * 功能实现：
 */
public class SmileDay00102Model extends BasterModel implements SmileDay00102Contion.moder {

    @Override
    public void getmoder(String name, SmileDay00102Callbcak callbck) {
        SmileDay00102Okhttp.getOkhttp().getRetrofit().create(SmileDay00102Api.class).getsmile(name)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.computation())
                .subscribe(new Observer<SmileDay00102Bean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(SmileDay00102Bean smileDay00102Bean) {
                        List<SmileDay00102Bean.DataBean> dataBeans = smileDay00102Bean.getData();
                        callbck.suees(dataBeans);
                    }

                    @Override
                    public void onError(Throwable e) {
                        callbck.filai("失败");
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
